<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>添加学生</title>
</head>

<body>
    <div>
        姓名：
        <input class="username" type="text" name="name">
    </div>
    <div>
        年龄：
        <input class="age" type="text" name="age">
    </div>
    <div>
        性别：
        <input class="sex" type="radio" name="sex" value="男">男
        <input class="sex" type="radio" name="sex" value="女">女
    </div>
    <div>
        班级：
        <input class="stu_class" type="text" name="class">
    </div>
    <div>
        <input class="btn" type="button" value="提交">
        <input type="reset">
    </div>


    <script src="./js/jquery-1.10.1.min.js"></script>
    <script>
        $('body').find('.btn').on('click', function () {
            $.post("./add_student.php", {
                name: $('.username').val(),
                age: $('.age').val(),
                sex: $('input:radio:checked').val(),
                class: $('.stu_class').val()
            }, function (data) {
                console.log(data);
                alert('添加成功！');
            });
        });
    </script>
</body>

</html>